var express = require('express');
var router = express.Router();

//引入方法
const { addAdmins, getAdmins, editAdmins, deleteAdmins, switchAdmins } = require('../service/adminsService.js')

//新增管理员
router.post('/addAdmins', async (req, res, next) => {
    const { account, password } = req.body;
    res.send(await addAdmins({ account, password }))
})

//获取所有管理员
router.get('/getAdmins', async (req, res, next) => {
    res.send(await getAdmins())
})

//update
router.post('/editAdmins', async (req, res, next) => {
    let { _id, account, password } = req.body;
    res.send(await editAdmins({ _id, account, password }))
})

//delete
router.post('/deleteAdmins', async (req, res, next) => {
    let { _id } = req.body;
    res.send(await deleteAdmins({ _id }))
})

//switchAdmins
router.post('/switchAdmins', async (req, res, next) => {
    let { _id, status } = req.body;
    res.send(await switchAdmins({ _id, status }))
})

module.exports = router;
